/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * SQLServerMainForm.java
 *
 * Created on May 14, 2012, 10:33:51 AM
 */
package sqlserver;

import Database.DatabasesManager;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JTabbedPane;

/**
 *
 * @author PHAMDANH
 */
public class SQLServerMainForm extends javax.swing.JFrame {

    /** Creates new form SQLServerMainForm */
    public SQLServerMainForm() {
        super("SQL Server Management");
        /*ServerManager server=new ServerManager(this);
        server.Init();
        try{
        server.Load();
        }catch(IOException cnfe){
        }*/
        initComponents();
        init();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pnlLeft = new javax.swing.JScrollPane();
        toolBar = new javax.swing.JToolBar();
        btNewQuery = new javax.swing.JButton();
        btOpen = new javax.swing.JButton();
        btSaveAll = new javax.swing.JButton();
        btSave = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        lblHostName = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        lblPort = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        lblIP = new javax.swing.JLabel();
        pnlRight = new javax.swing.JScrollPane();
        jToolBar1 = new javax.swing.JToolBar();
        jLabel4 = new javax.swing.JLabel();
        cbCurrentDatabase = new javax.swing.JComboBox();
        menuBar = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        openMenuItem = new javax.swing.JMenuItem();
        saveMenuItem = new javax.swing.JMenuItem();
        saveAllMenuItem = new javax.swing.JMenuItem();
        exitMenuItem = new javax.swing.JMenuItem();
        helpMenu = new javax.swing.JMenu();
        aboutMenuItem = new javax.swing.JMenuItem();
        editMenu = new javax.swing.JMenu();
        cutMenuItem = new javax.swing.JMenuItem();
        copyMenuItem = new javax.swing.JMenuItem();
        pasteMenuItem = new javax.swing.JMenuItem();
        deleteMenuItem = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        pnlLeft.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Server Explorer", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font(".VnArial", 0, 14))); // NOI18N
        pnlLeft.setToolTipText("");
        pnlLeft.setName(""); // NOI18N

        toolBar.setRollover(true);

        btNewQuery.setFont(new java.awt.Font("Tahoma", 0, 12));
        btNewQuery.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/new.png"))); // NOI18N
        btNewQuery.setText("New Query");
        btNewQuery.setFocusable(false);
        btNewQuery.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btNewQuery.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btNewQueryMouseClicked(evt);
            }
        });
        toolBar.add(btNewQuery);

        btOpen.setFont(new java.awt.Font("Tahoma", 0, 12));
        btOpen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/open.png"))); // NOI18N
        btOpen.setText("Open");
        btOpen.setFocusable(false);
        btOpen.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btOpen.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btOpenMouseClicked(evt);
            }
        });
        toolBar.add(btOpen);

        btSaveAll.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        btSaveAll.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/save_all.png"))); // NOI18N
        btSaveAll.setText("Save All");
        btSaveAll.setFocusable(false);
        btSaveAll.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btSaveAll.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btSaveAllMouseClicked(evt);
            }
        });
        toolBar.add(btSaveAll);

        btSave.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        btSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/save.png"))); // NOI18N
        btSave.setText("Save");
        btSave.setFocusable(false);
        btSave.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btSave.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btSaveMouseClicked(evt);
            }
        });
        btSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSaveActionPerformed(evt);
            }
        });
        toolBar.add(btSave);

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel1.setText("Host Name: ");

        lblHostName.setFont(new java.awt.Font("Tahoma", 0, 12));
        lblHostName.setText("ten host");

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel2.setText("Port: ");

        lblPort.setFont(new java.awt.Font("Tahoma", 0, 12));
        lblPort.setText("so port");

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel3.setText("Host IP: ");

        lblIP.setFont(new java.awt.Font("Tahoma", 0, 12));
        lblIP.setText("ip host");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblHostName)
                .addGap(132, 132, 132)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblIP)
                .addGap(126, 126, 126)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblPort)
                .addContainerGap(341, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel3)
                    .addComponent(jLabel2)
                    .addComponent(lblIP)
                    .addComponent(lblHostName)
                    .addComponent(lblPort))
                .addContainerGap())
        );

        pnlRight.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Content", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font(".VnArial", 0, 14))); // NOI18N

        jToolBar1.setRollover(true);

        jLabel4.setText("Current Database: ");
        jToolBar1.add(jLabel4);

        cbCurrentDatabase.setMaximumSize(new java.awt.Dimension(300, 30));
        cbCurrentDatabase.setMinimumSize(new java.awt.Dimension(200, 30));
        cbCurrentDatabase.setName(""); // NOI18N
        cbCurrentDatabase.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbCurrentDatabaseItemStateChanged(evt);
            }
        });
        jToolBar1.add(cbCurrentDatabase);

        fileMenu.setMnemonic('f');
        fileMenu.setText("File");

        openMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/open.png"))); // NOI18N
        openMenuItem.setMnemonic('o');
        openMenuItem.setText("Open");
        openMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                openMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(openMenuItem);

        saveMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/save.png"))); // NOI18N
        saveMenuItem.setMnemonic('s');
        saveMenuItem.setText("Save");
        saveMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(saveMenuItem);

        saveAllMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/save_all.png"))); // NOI18N
        saveAllMenuItem.setMnemonic('a');
        saveAllMenuItem.setText("Save All");
        saveAllMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveAllMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(saveAllMenuItem);

        exitMenuItem.setMnemonic('x');
        exitMenuItem.setText("Exit");
        exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        helpMenu.setMnemonic('h');
        helpMenu.setText("Help");

        aboutMenuItem.setMnemonic('a');
        aboutMenuItem.setText("About");
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        editMenu.setMnemonic('e');
        editMenu.setText("Edit");

        cutMenuItem.setMnemonic('t');
        cutMenuItem.setText("Cut");
        editMenu.add(cutMenuItem);

        copyMenuItem.setMnemonic('y');
        copyMenuItem.setText("Copy");
        editMenu.add(copyMenuItem);

        pasteMenuItem.setMnemonic('p');
        pasteMenuItem.setText("Paste");
        editMenu.add(pasteMenuItem);

        deleteMenuItem.setMnemonic('d');
        deleteMenuItem.setText("Delete");
        editMenu.add(deleteMenuItem);

        menuBar.add(editMenu);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(pnlLeft, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(pnlRight, javax.swing.GroupLayout.DEFAULT_SIZE, 691, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addComponent(toolBar, javax.swing.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 533, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(toolBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(pnlRight, javax.swing.GroupLayout.DEFAULT_SIZE, 562, Short.MAX_VALUE)
                    .addComponent(pnlLeft, javax.swing.GroupLayout.DEFAULT_SIZE, 562, Short.MAX_VALUE)))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
        System.exit(0);
    }//GEN-LAST:event_exitMenuItemActionPerformed

private void btOpenMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btOpenMouseClicked
// TODO add your handling code here:
    OpenFile();
}//GEN-LAST:event_btOpenMouseClicked
public void OpenFile()
{
    JFileChooser chooser = new JFileChooser();
    chooser.setDialogTitle("Open file");
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    MyExtensionFileFilter filter = new MyExtensionFileFilter("Query file", new String[]{"sql"});
    chooser.addChoosableFileFilter(filter);
    int returnVal = chooser.showOpenDialog(this);    
    if(returnVal == JFileChooser.APPROVE_OPTION) 
    {
        String path =chooser.getSelectedFile().getPath();
        if( !"".equals(path))
        {        
            File fileSrc = new File(path);
            String value = ViewFile(fileSrc);  
            QueryPanel panel = new QueryPanel(this.getDatabasesManager());
            panel.setText(value);
            String tabName = fileSrc.getName();
            getTabbedPane().addTab(tabName, panel);
        }
    }
}
public String ViewFile(File srcFile)
{
    String content = null;
    FileReader file = null;
    try 
    {
        file = new FileReader(srcFile);
    } 
    catch (FileNotFoundException ex) 
    {       
    }
    BufferedReader br = new BufferedReader(file);
    String strLine = null ;
    while (true)
    {
        try 
        {
            strLine = br.readLine();
        }
        catch (IOException ex) 
        {            
        }
        if (strLine == null)
            break;
        content += strLine;
        content += "\n";
    }
    return content;
}
int countQuery = 0;
private void btNewQueryMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btNewQueryMouseClicked
// TODO add your handling code here:
    QueryPanel panel = new QueryPanel(this.getDatabasesManager());
    String tabName = "Query"+ (countQuery + 1) +".sql";
    countQuery++;
    getTabbedPane().addTab(tabName, panel);
    getTabbedPane().setSelectedIndex(getTabbedPane().getTabCount()-1);
}//GEN-LAST:event_btNewQueryMouseClicked

private void btSaveAllMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btSaveAllMouseClicked
// TODO add your handling code here:
    SaveAll();
}//GEN-LAST:event_btSaveAllMouseClicked

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        // TODO add your handling code here:
        svrManager.Dispose();
    }//GEN-LAST:event_formWindowClosing

private void cbCurrentDatabaseItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbCurrentDatabaseItemStateChanged
// TODO add your handling code here:
    int idx=cbCurrentDatabase.getSelectedIndex();
    if(idx>=0)
        svrManager.getDatabasesManager().setDatabaseIdx(idx);
}//GEN-LAST:event_cbCurrentDatabaseItemStateChanged

private void saveAllMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveAllMenuItemActionPerformed
// TODO add your handling code here:
    SaveAll();
}//GEN-LAST:event_saveAllMenuItemActionPerformed

private void openMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openMenuItemActionPerformed
// TODO add your handling code here:
    OpenFile();
}//GEN-LAST:event_openMenuItemActionPerformed

private void saveMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveMenuItemActionPerformed
// TODO add your handling code here:
    Save();
}//GEN-LAST:event_saveMenuItemActionPerformed
public void SaveAll()
{
    if(svrManager.getDatabasesManager().SaveAll())
    {
        JOptionPane.showMessageDialog(null, "Lưu thành công");
    }
    else
        JOptionPane.showMessageDialog(null, "Lưu thất bại");
}
public void Save()
{
    int idx=cbCurrentDatabase.getSelectedIndex();
    if(idx>=0)
    if(svrManager.getDatabasesManager().getDatabases().get(idx).Save())
        JOptionPane.showMessageDialog(null, "Lưu database hiện tại thành công");
    else
        JOptionPane.showMessageDialog(null, "Lưu database hiện tại thất bại");
}
private void btSaveMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btSaveMouseClicked
// TODO add your handling code here:
}//GEN-LAST:event_btSaveMouseClicked

private void btSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSaveActionPerformed
// TODO add your handling code here:
    Save();
}//GEN-LAST:event_btSaveActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(SQLServerMainForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(SQLServerMainForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(SQLServerMainForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(SQLServerMainForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new SQLServerMainForm().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem aboutMenuItem;
    private javax.swing.JButton btNewQuery;
    private javax.swing.JButton btOpen;
    private javax.swing.JButton btSave;
    private javax.swing.JButton btSaveAll;
    private javax.swing.JComboBox cbCurrentDatabase;
    private javax.swing.JMenuItem copyMenuItem;
    private javax.swing.JMenuItem cutMenuItem;
    private javax.swing.JMenuItem deleteMenuItem;
    private javax.swing.JMenu editMenu;
    private javax.swing.JMenuItem exitMenuItem;
    private javax.swing.JMenu fileMenu;
    private javax.swing.JMenu helpMenu;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JLabel lblHostName;
    private javax.swing.JLabel lblIP;
    private javax.swing.JLabel lblPort;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JMenuItem openMenuItem;
    private javax.swing.JMenuItem pasteMenuItem;
    private javax.swing.JScrollPane pnlLeft;
    private javax.swing.JScrollPane pnlRight;
    private javax.swing.JMenuItem saveAllMenuItem;
    private javax.swing.JMenuItem saveMenuItem;
    private javax.swing.JToolBar toolBar;
    // End of variables declaration//GEN-END:variables
   
    private ServerManager svrManager;    
    
    public JTabbedPane getTabbedPane()
    {
        return svrManager.getTabbedPane();
    }
    public DatabasesManager getDatabasesManager()
    {
        return svrManager.getDatabasesManager();
    }
    public void RefreshComboBoxCurrentDatabase()
    {
        cbCurrentDatabase.removeAllItems();
        for(int i=0;i<getDatabasesManager().getDatabases().size();i++)
            cbCurrentDatabase.addItem(getDatabasesManager().getDatabases().get(i).getName());
    }
    private void init() 
    {
        svrManager = new ServerManager(this);    
        RefreshComboBoxCurrentDatabase();
        pnlLeft.setViewportView(svrManager.getTree());  
        pnlRight.setViewportView(svrManager.getTabbedPane());
        //Thong tin host        
        lblHostName.setText(svrManager.getHostName());
        lblIP.setText(svrManager.getHostIP());
        String port = ((Integer)svrManager.getPort()).toString();
        lblPort.setText(port);
    }
}
